package com.umeng.analytics.game;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences;
import android.text.TextUtils;

import com.umeng.analytics.pro.ax;
import com.umeng.analytics.pro.ba;

import java.io.Serializable;

public class b {
    class a implements Serializable {
        private static final long a = 20140327;
        private String b;
        private long c;
        private long d;

        public a(String arg1) {

            this.b = arg1;
        }

        public void a() {
            this.d = System.currentTimeMillis();
        }

        public boolean a(String arg2) {
            return this.b.equals(arg2);
        }

        public void b() {
            this.c += System.currentTimeMillis() - this.d;
            this.d = 0;
        }

        public void c() {
            this.a();
        }

        public void d() {
            this.b();
        }

        public long e() {
            return this.c;
        }

        public String f() {
            return this.b;
        }
    }

    public String a;
    public String b;
    private Context c;
    private final String d;
    private final String e;
    private final String f;
    private final String g;
    private a h;

    public b(Context arg2) {

        this.d = "um_g_cache";
        this.e = "single_level";
        this.f = "stat_player_level";
        this.g = "stat_game_level";
        this.h = null;
        this.c = arg2;
    }

    public a a(String arg2) {
        this.h = new a(arg2);
        this.h.a();
        return this.h;
    }

    public void a() {
        if (this.h != null) {
            this.h.b();
            SharedPreferences.Editor v0 = this.c.getSharedPreferences("um_g_cache", 0).edit();
            v0.putString("single_level", ax.a(this.h));
            v0.putString("stat_player_level", this.b);
            v0.putString("stat_game_level", this.a);
            v0.commit();
        }
    }

    public a b(String arg3) {
        a v0;
        a v1 = null;
        if (this.h != null) {
            this.h.d();
            if (this.h.a(arg3)) {
                v0 = this.h;
                this.h = v1;
            } else {
                v0 = v1;
            }
        } else {
            v0 = v1;
        }

        return v0;
    }

    public void b() {
        String v3 = null;
        SharedPreferences v1 = ba.a(this.c, "um_g_cache");
        String v0 = v1.getString("single_level", v3);
        if (!TextUtils.isEmpty(((CharSequence) v0))) {
            this.h = (com.umeng.analytics.game.b.a) ax.a(v0);
            if (this.h != null) {
                this.h.c();
            }
        }

        if (TextUtils.isEmpty(this.b)) {
            this.b = v1.getString("stat_player_level", v3);
            if (this.b == null) {
                SharedPreferences v0_1 = ba.a(this.c);
                if (v0_1 != null) {
                    this.b = v0_1.getString("userlevel", v3);
                    if (this.a == null) {
                        this.a = v1.getString("stat_game_level", v3);
                    }
                }
            } else {
                if (this.a == null) {
                    this.a = v1.getString("stat_game_level", v3);
                }
            }
        } else {
            if (this.a == null) {
                this.a = v1.getString("stat_game_level", v3);
            }
        }
    }
}

